package com.weixing.mall.provider.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.weixing.mall.provider.mapper.PhotoGalleryMapper;
import com.weixing.mall.provider.model.domain.PhotoGallery;
import com.weixing.mall.provider.model.dto.PhotoChgDto;
import com.weixing.mall.provider.model.dto.PhotoGalleryDto;
import com.weixing.mall.provider.model.query.PhotoGalleryQuery;
import com.weixing.mall.provider.model.vo.PhotoGalleryVo;
import com.weixing.mall.provider.service.IPhotoGalleryService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * @ClassName PhotoGalleryServiceImpl
 * @Description TODO <br/>
 * @Author gjq
 * @Modified By:
 * @Date 2019/8/9
 * @Version 1.0
 **/
/**
 * <p>
 * 商品模块-图片库表 服务实现类
 * </p>
 *
 * @author Small
 * @since 2019-11-20
 */
@Service
public class PhotoGalleryServiceImpl extends ServiceImpl<PhotoGalleryMapper, PhotoGallery> implements IPhotoGalleryService {

    @Override
    public void save(PhotoGalleryDto photoGalleryDto) {
        PhotoGallery photoGallery = new PhotoGallery();
        BeanUtils.copyProperties(photoGalleryDto,photoGallery);
        photoGallery.setIsEnable(photoGalleryDto.getIsEnable().getValue());
        if (null == photoGalleryDto.getId()){
            save(photoGallery);
        }else{
            updateById(photoGallery);
        }
    }

    @Override
    public IPage<PhotoGalleryVo> selectOfPage(Page page, PhotoGalleryQuery photoGalleryQuery) {
        return baseMapper.selectList(page,photoGalleryQuery);
    }

    @Override
    public int update(PhotoChgDto photoChgDto) {
        return baseMapper.updatePhoto(photoChgDto);
    }


}
